package com.lovo.csc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lovo.csc.bean.UserInfoBean;
import com.lovo.csc.mapper.IUserInfoMapper;
import com.lovo.csc.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserInfoServiceImpl implements IUserInfoService {

    @Autowired
    IUserInfoMapper userInfoMapper;
    @Override
    public void update(long userId,String content,String adminName) {
        QueryWrapper<UserInfoBean> qw = new QueryWrapper<>();
        qw.eq("fk_userId",userId);
        UserInfoBean userInfoBean = userInfoMapper.selectOne(qw);
        userInfoBean.setAdminName(adminName);
        userInfoBean.setContent(content);
        userInfoMapper.insert(userInfoBean);
    }

    public UserInfoBean findById(long userId){
        QueryWrapper<UserInfoBean>qw  = new QueryWrapper<>();
        qw.eq("fk_userId",userId);
      return   userInfoMapper.selectOne(qw);
    }
}
